package com.lgCore.common;

import com.esotericsoftware.kryo.serializers.JavaSerializer;
import com.lgCore.message.CommonRpcRequest;
import com.lgCore.message.CommonRpcResponse;
import com.lgCore.netty.message.*;
import com.lgCore.util.ClassUtil;
import com.lgCore.util.KryoUtils;

import java.util.Set;

public class ProtocolCore {

    //kyro注入类
    public static void kyroClass(){
        int index=1;
        KryoUtils.registerClass(CommonRpcRequest.class, new JavaSerializer(),index++);
        KryoUtils.registerClass(CommonRpcResponse.class, new JavaSerializer(),index++);
        Set<Class<?>>  classSet = ClassUtil.getClasses("com.lgCore.netty.message");
        for(Class c: classSet){
            KryoUtils.registerClass(c, new JavaSerializer(),index++);
        }
    }
}
